package com.jike.noobmoney.mvp.presenter;


import com.jike.noobmoney.entity.BaseEntity;
import com.jike.noobmoney.entity.CheckNumEntity;
import com.jike.noobmoney.entity.CheckinEntity;
import com.jike.noobmoney.entity.InviteListEntity;
import com.jike.noobmoney.entity.MessageEntity;
import com.jike.noobmoney.entity.MoneyEntity;
import com.jike.noobmoney.entity.NewTaskListEntity;
import com.jike.noobmoney.entity.NumEntity;
import com.jike.noobmoney.entity.RedrotEntity;
import com.jike.noobmoney.net.BaseSubscriber;
import com.jike.noobmoney.net.IView;


/**
 * 任务
 */
public class UserPresenter extends BasePresenter<IView> {

    public UserPresenter(IView view) {
        super(view);
    }

    /**
     * 余额
     */
    public void moneyView(String userid, final String type) {

        addSubscription(iHttpUrl.moneyView(userid), new BaseSubscriber<MoneyEntity>() {
            @Override
            public void onNext(MoneyEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getUser(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }
    /**
     * 上传广告信息
     */
    public void updateVideo(String userid, final String type) {

        addSubscription(iHttpUrl.updateVideo(userid), new BaseSubscriber<MoneyEntity>() {
            @Override
            public void onNext(MoneyEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getUser(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 新手任务
     */
    public void newusertasklist(String userid, final String type) {

        addSubscription(iHttpUrl.newusertasklist(userid), new BaseSubscriber<NewTaskListEntity>() {
            @Override
            public void onNext(NewTaskListEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 视频回调
     */
    public void callbackVideo(String userid,String deviceno,Integer  type,Integer ischeck,long time,String sign, final String typen) {

        addSubscription(iHttpUrl.callbackVideo(userid,deviceno,type,ischeck,time,sign), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity, typen);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 时长游戏回调
     */
    public void callbackGame(String userid,String deviceno,String  gameid,String gamename,String gametype,Integer time,String sign, final String typen) {

        addSubscription(iHttpUrl.callbackGame(userid,deviceno,gameid,gamename,gametype,time,sign), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity, typen);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 完成任务情况
     */
    public void getNum(String userid, final String type) {

        addSubscription(iHttpUrl.getNum(userid), new BaseSubscriber<NumEntity>() {
            @Override
            public void onNext(NumEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 每日签到完成任务情况
     */
    public void getCheckNum(String userid, final String type) {

        addSubscription(iHttpUrl.getCheckNum(userid), new BaseSubscriber<CheckNumEntity>() {
            @Override
            public void onNext(CheckNumEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 新手完成任务领取奖金
     */
    public void newusertaskreceive(String userid, String flag, final String type) {

        addSubscription(iHttpUrl.newusertaskreceive(userid, flag), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 每日签到领取奖金
     */
    public void checkinreceive(String userid, String flag, final String type) {

        addSubscription(iHttpUrl.checkinreceive(userid, flag), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 新手完成任务领取奖金
     */
    public void getreceive(String userid, String flag, final String type) {

        addSubscription(iHttpUrl.taskusertaskreceive(userid, flag), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 完成任务
     */
    public void newusertasksuccess(String userid, String flag, final String type) {

        addSubscription(iHttpUrl.newusertasksuccess(userid, flag), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 提交审核
     */
    public void newusertaskimage(String userid, String flag, String image, final String type) {

        addSubscription(iHttpUrl.newusertaskimage(userid, flag, image), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getInfo(), entity, type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getInfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 邀请好友列表
     */
    public void userinvitelist(String userid, final String type) {

        addSubscription(iHttpUrl.userinvitelist(userid), new BaseSubscriber<InviteListEntity>() {
            @Override
            public void onNext(InviteListEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getUserinvitelist(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 签到
     */
    public void checkin(String userid, final String type) {

        addSubscription(iHttpUrl.checkin(userid), new BaseSubscriber<CheckinEntity>() {
            @Override
            public void onNext(CheckinEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getMoney(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 提现
     */
    public void tixian(String u_id,  String money, final String type) {

        addSubscription(iHttpUrl.getTiXian(u_id, money), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 微信账号绑定
     */
    public void bindWx(String openid,String wxnick,String sign, final String type) {

        addSubscription(iHttpUrl.bindWX(openid, wxnick,sign), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }





    /**
     * 余额微信提现
     */
    public void tiwxxian(String u_id,  String money, final String type) {

        addSubscription(iHttpUrl.getWXTiXian(u_id, money), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 任务支付宝提现
     */
    public void rwtixian(String u_id,  String money, final String type) {

        addSubscription(iHttpUrl.getrwTiXian(u_id, money), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 任务微信提现
     */
    public void rwwxtixian(String u_id,  String money, final String type) {

        addSubscription(iHttpUrl.getrwWXTiXian(u_id, money), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 消息
     */
    public void getMessage(String userid, final String type) {

        addSubscription(iHttpUrl.getMessage(userid), new BaseSubscriber<MessageEntity>() {
            @Override
            public void onNext(MessageEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getMessage(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 获取消息的未读数
     */
    public void getRedrot(String userid, final String type) {

        addSubscription(iHttpUrl.getRedrot(userid), new BaseSubscriber<RedrotEntity>() {
            @Override
            public void onNext(RedrotEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), "" + entity.getNumber(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 设置已读
     */
    public void setReaded(String userid, String msg_id, final String type) {

        addSubscription(iHttpUrl.setReaded(userid, msg_id), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


    /**
     * 修改昵称
     */
    public void editUserInfo1(String u_id, String nick, String name, String iicard,String alipayaccount,String phone,String code, String type) {

        addSubscription(iHttpUrl.editUserInfo1(u_id, nick, name, iicard,alipayaccount,phone,code), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }

    /**
     * 修改头像
     */
    public void editUserInfo2(String u_id, String avatar, String type) {

        addSubscription(iHttpUrl.editUserInfo2(u_id, avatar), new BaseSubscriber<BaseEntity>() {
            @Override
            public void onNext(BaseEntity entity) {
                if ("100".equals(entity.getCode())) {
                    iView.onSuccess(entity.getCode(), entity.getRinfo(), entity.getRinfo(), type);
                } else {
                    iView.onFailed(entity.getCode(), entity.getRinfo());
                }
            }

            @Override
            public void onFailed(String code, String msg) {
                iView.onFailed(code, msg);
            }
        });
    }


}
